<?php

namespace app\weixin\behavior;

use app\common\model\Member;
use app\common\util\LoginManager;


/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/6/21
 * Time: 17:51
 */
class CheckAuth
{
    public function run()
    {
        $uri = trim($_SERVER['REQUEST_URI']);
        if ($uri == '/' || $uri == ''
            || strpos($uri, '/weixin/index/info') === 0
            || strpos($uri, '/weixin/index/index') === 0
            || strpos($uri, U('index/company')) === 0
            || strpos($uri, U('index/saveInfo')) === 0
            || strpos($uri, U('index/saveCompanyInfo')) === 0
        ) {
            return;
        }
        $user = Member::instance()->where(['id' => LoginManager::getLoginUserId()])->find();
        if (empty($user['username']) || empty($user['telephone'])) {
            ccnn_redirect('/weixin/index/info');
        }
    }
}